#include<bits/stdc++.h>
using namespace std;

int n, m;
int a[100005];


bool chk(int x) {
    int sum = 0;
    for(int i = 1 ; i <= n ; i++)
        sum += min(x , a[i]);
    return sum >= m * x;
}


signed main() {
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    sort(a + 1, a + n + 1);

    int l = 0, r = n, mid;

    while(l + 1 != r) {
        mid = (r - l) / 2 + l;
        if(chk(mid))
            l = mid;
        else
            r = mid;
    }

    cout << l;

    return 0;
}

